<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        [v-cloak] {
            display: none
        }

        * {
            list-style: none;
            margin: 0;
            padding: 0;
        }

        .list {
            display: flex;
        }

        .list li {
            padding: 10px 20px;
            margin: 10px;
            cursor: pointer;
            user-select: none;
        }

        .list li.active {
            background: orangered;
            color: #fff;
        }

        .container {
            width: 800px;
            margin: 50px auto;
            border: 1px solid #eee;
            padding: 20px;
        }

        .showlist li {
            padding: 20px;
            border: 1px dashed #eee;
            display: flex;
        }

        .showlist li img {
            width: 150px;
            height: 200px;
        }

        .showlist li .content {
            padding: 10px;
        }

        .showlist li .content .title {
            font-size: 18px;
        }

        .showlist li .content .desc>div {
            padding: 13px 5px;
            font-size: 13px;
            color: #ccc;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak>
        <div class="container">
            <ul class="list">
                <li>城市：</li>
                <li @click="activeCityId=item.id" v-for="item in cityList" :class="{active:item.id === activeCityId}">
                    {{item.name}}
                </li>
            </ul>
            <ul class="list">
                <li>类型：</li>
                <li @click="activeTypeId=item.id" v-for="item in typeList" :class="{active:item.id === activeTypeId}">
                    {{item.name}}
                </li>
            </ul>
            <ul class="showlist">
                <li v-for="item in showList">
                    <img :src="item.img">
                    <div class="content">
                        <div class="title">【{{item.city}}】{{item.title}}</div>
                        <div class="desc">
                            <div>艺人：{{item.artistname}}</div>
                            <div>{{item.city}} | {{item.address}}</div>
                            <div>{{item.showtime | fmtTime}}</div>
                            <div>300 元 {{item.state | fmtState}}</div>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </div>
    <script src="https://cdn.bootcss.com/vue/2.6.10/vue.js"></script>
    <script src="https://cdn.bootcss.com/axios/0.19.0-beta.1/axios.js"></script>
    <script src="https://gitee.com/shendusimba/simbajs/raw/master/simba.js"></script>
    <script>
        Vue.filter("fmtState", val => {
            switch (val) {
                case 0:
                    return '售票中'
                case 1:
                    return '售罄'
                case 2:
                    return '待开票'
                default:
                    return '其他'
            }
        })

        Vue.filter("fmtTime", val => {
            var now = new Date(val)
            return now.getFormatText()
        })
        new Vue({
            el: "#app",

            data() {
                return {
                    activeCityId: 0,
                    activeTypeId: 0,
                    showList: [],
                    cityList: [
                        { id: 0, name: "全部" },
                        { id: 1, name: "南京" },
                        { id: 2, name: "上海" }
                    ],
                    typeList: [
                        { id: 0, name: "全部" },
                        { id: 1, name: "演唱会" },
                        { id: 2, name: "音乐会" }
                    ]
                }
            },
            created() {
                axios.get('http://192.168.10.66:5000/show/showList').then(res => {
                    this.showList = res.data
                })
              
            }
            
        })        
    </script>
</body>

</html>